/**
 * 
 */
package com.nassir.excel.cellwriter;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;

import com.nassir.excel.model.Cell;

/**
 * @author zhangqiulong
 *
 */
public class DoubleCellWriter implements ICellWriter<Double> {

	public boolean accept(String type) {
		return CELL_TYPE_DOUBLE.equals(type);
	}

	public void write(HSSFCell cell, Cell head, Double data) {
	  /* cell.setCellValue(data);
       HSSFCellStyle cellStyle = cell.getSheet().getWorkbook().createCellStyle(); 
       cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat(head.getFormat())); 
       cell.setCellStyle(cellStyle);*/
       
       
       
      // double data=Double.valueOf( data.toString());
		 cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
	     cell.setCellValue(data);
	     
	     
      HSSFCellStyle cellStyle = cell.getSheet().getWorkbook().createCellStyle(); 
      HSSFDataFormat dataformat = cell.getSheet().getWorkbook().createDataFormat();
      cellStyle.setDataFormat(dataformat.getFormat(head.getFormat())); 
      cell.setCellStyle(cellStyle); 
	}

}
